package com.woorigil.social.domain.category;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.woorigil.social.Context;
import com.woorigil.social.domain.deal.Deal;

@Component (value="OCMapper")
public class OclockCategoryMapper implements CategoryMapper {
	
	Map<String, List<String>> shoppings = new HashMap<String, List<String>>() {{
		put("가전", Arrays.asList("계절가전", "주방가전"));
		put("생활/주방", Arrays.asList("주방", "욕실용품", "생활잡화", "생활가구", "문구/사무", "의료기기", "발육용품"));
		put("출산/유아동", Arrays.asList("학습용교구", "출산용품", "임부용의류", "유아동잡화", "유아동의류", "유아동도서", "완구"));
		put("뷰티", Arrays.asList("화장품", "헬스", "이미용품", "이미용기기"));
		put("식품", Arrays.asList("축산물", "수산물", "농산물", "건강식품", "가공식품"));
		put("스포츠/레저", Arrays.asList("자동차", "스포츠신발", "스포츠의류", "레저용품", "레저", "건강용품"));
		put("디지털", Arrays.asList("통신기기", "컴퓨터하드웨어", "미디어"));
		put("패션잡화", Arrays.asList("패션신발", "패션소품", "지갑", "액세서리", "시계", "가방"));
		put("홈/데코/취미", Arrays.asList("카페트/자리", "침구", "취미", "인테리어용품", "시스템가구", "수납용품", "용역"));
		put("의류", Arrays.asList("여성의류", "남성의류", "남녀공용의류"));
	}};

	@Override
	public int getCategoryId(Deal deal) {
		int categoryId = Context.getCategoryId(getCategoryName(deal.getCategory()));
		return (categoryId == 0)? 100 : categoryId;
	}
	
	private String getCategoryName(String categoryName) {
		for (String subMenuName : shoppings.keySet()) {
			List<String> shoppingSectionNames = shoppings.get(subMenuName);
			if (shoppingSectionNames.contains(categoryName)) {
				return subMenuName;
			}
		}

		return null;
	}
}
